home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / amos / amsls396.lzh / AMOSLIST / 000021_currie@cpsc.ucalgary.ca_Mon Mar 4 03:51:01 1996.msg < prev    next >
Internet Message Format  |  1996-04-01  |  3KB

  1. Received: from conan.eds-ms.com (conan.eds-ms.com [204.240.136.11]) by mail1.access.digex.net (8.6.12/8.6.12) with SMTP id DAA19261;  for <mcox@access.digex.net> ; Mon, 4 Mar 1996 03:50:46 -0500
  2. Received: from fsa.cpsc.ucalgary.ca by conan.eds-ms.com (5.x/SMI-SVR4)
  3.     id AA21511; Mon, 4 Mar 1996 03:27:29 -0500
  4. Received: from fsf.cpsc.ucalgary.ca (fsf.cpsc.ucalgary.ca [136.159.2.6])
  5.     by fsa.cpsc.ucalgary.ca (1.8) id <BAA29573@fsa.cpsc.ucalgary.ca>;
  6.     Mon, 4 Mar 1996 01:27:23 -0700
  7. From: currie@cpsc.ucalgary.ca (Robert Currie)
  8. Received: by fsf.cpsc.ucalgary.ca (1.2; from currie@localhost)
  9.     id <BAA14611@fsf.cpsc.ucalgary.ca>; Mon, 4 Mar 1996 01:27:21 -0700
  10. Message-Id: <199603040827.BAA14611@fsf.cpsc.ucalgary.ca>
  11. Subject: Re: Clipped line
  12. To: cosmo@sci.fi (Ville Ranki)
  13. Date: Mon, 4 Mar 1996 01:27:21 -0700 (MST)
  14. Cc: amos-list@conan.eds-ms.com
  15. In-Reply-To: <Pine.sol.3.90.960303215910.21595B-100000@borg> from "Ville Ranki" at Mar 3, 96 10:03:26 pm
  16. Content-Type: text
  17. Status: RO
  18. X-Status: 
  19.  
  20. > Hi!
  21. > I'd need a procedure that 'Clips' a drawn line to the screen.
  22. > Amos crashes when my program draws >10000 pixels long lines, and the Amos=
  23. > =20
  24. > Clip command doesn't help.=20
  25. > The procedure should work line Draw command, and it should use variables=20
  26. > XMIN, XMAX, YMIN, and YMAX to set the drawing area.
  27. > Can anyone help?
  28. >
  29.  
  30. You should try to implement a binary search of coordinates along the line 
  31. in question. The routine should follow this method:
  32.  
  33. Check boundary conditions-- If its totally in, draw the line
  34.                             If its totally out, discard it
  35.       
  36. If one endpoint is in then
  37. Recursively discard segments of the line--
  38.   (Can be implemented with a while loop)
  39.   Find the midpoint of the line inx,iny-->outx,outy
  40.   Is that point within the clip region?
  41.      If it is, temparily adopt that as the new 'in' point
  42.      If it isn't then adopt it as the new 'out' point
  43.   Recurse until one of the coordinates equals one of the clip coordinates
  44. Draw line using the final point 
  45.  
  46. If both endpoints are out but a line segment is in then
  47.   Binary search the line to find a point that resides in the clip zone
  48.   Find endpoints using a technique similar to the one above
  49.   Draw the two lines
  50.  
  51. Exit
  52.  
  53.  
  54.  
  55. Either that or you can simply write your own line routine and not plot points
  56. that occur outside of the clip plane. There are several good line algorithms
  57. that can be used such as Bresenhams algorithm for line drawing which only
  58. uses incremetal integer calculations.
  59.  
  60.  
  61.                 Robert Currie
  62.                 
  63.                 currie@cpsc.ucalgary.ca
  64.                 http://www.cpsc.ucalgary.ca/~currie
  65.  
  66.